package org.csu.jpetstorespringversion.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.jpetstorespringversion.mapper.SequenceMapper;
import org.csu.jpetstorespringversion.model.Sequence;
import org.csu.jpetstorespringversion.service.SequenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SequenceServiceImpl extends ServiceImpl<SequenceMapper,Sequence> implements SequenceService {
    @Autowired
    SequenceMapper sequenceMapper;
    @Override
    public Sequence getSequence(Sequence sequence) {
        QueryWrapper<Sequence> wrapper = new QueryWrapper<>();
        wrapper.eq("name",sequence.getName());
        Sequence sequence1= sequenceMapper.selectOne(wrapper);
        return sequence1;
    }

    @Override
    public void updateSequence(Sequence sequence) {
        QueryWrapper<Sequence> wrapper =new QueryWrapper<>();
         wrapper.eq("name",sequence.getName());
        int result =  sequenceMapper.update(sequence,wrapper);
        System.out.println(result);

    }
}
